from django.conf.urls import url
from django.contrib import admin
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import statistical, users, specs, images, skus, orders, permissions, group, admin

urlpatterns = [
    # 登录
    url(r'^authorizations/$', obtain_jwt_token),
    # ----------用户统计-----------
    # 统计用户总量
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    # 日增用户统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 日活用户统计
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    # 日下单用户统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    # 月增用户统计(每天)
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    # 日分类商品访问量统计
    url(r'^statistical/goods_day_views/$', statistical.UserGoodsCountView.as_view()),
    # ----------用户管理---------------------
    url(r'^users/$', users.UserView.as_view()),
    # ----------商品规格路由-------------
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # ----------图片路由-------------
    url(r'^skus/simple/$', images.ImagesView.as_view({'get': 'simple'})),
    # ----------sku路由-------------
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SkusView.as_view({'get': 'specs'})),
    # ----------权限路由-------------
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_type'})),
    url(r'^permission/simple/$', group.GroupView.as_view({'get': 'simple'})),
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),
]
# -----------商品规格--------------------
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='specs')
urlpatterns += router.urls

# -----------商品图片--------------------
router = DefaultRouter()
router.register('skus/images', images.ImagesView, base_name='images')
urlpatterns += router.urls

# -----------sku表信息--------------------
router = DefaultRouter()
router.register('skus', skus.SkusView, base_name='skus')
urlpatterns += router.urls

# -----------订单表信息--------------------
router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# -----------权限路由--------------------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionView, base_name='perms')
urlpatterns += router.urls

# -----------分组路由--------------------
router = DefaultRouter()
router.register('permission/groups', group.GroupView, base_name='groups')
print(router.urls)
urlpatterns += router.urls

# -----------管理员管理路由--------------------
router = DefaultRouter()
router.register('permission/admins', admin.AdminView, base_name='admins')
print(router.urls)
urlpatterns += router.urls
